//
//  TicketImageCollectionCell.m
//  MerieuxWskProj
//
//  Created by 焱 孙 on 16/1/2.
//  Copyright © 2016年 visionet. All rights reserved.
//

#import "TicketImageCollectionCell.h"
#import "UIImage+Extras.h"
#import "UIImageView+WebCache.h"

@interface TicketImageCollectionCell ()
{
    AttachmentVo *attachmentVoData;
}

@end

@implementation TicketImageCollectionCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // Initialization code
        //改变选中背景色
        UIView *viewSelected = [[UIView alloc] initWithFrame:self.frame];
        viewSelected.backgroundColor = TABLEVIEW_SELECTED_COLOR;
        self.selectedBackgroundView = viewSelected;
        
        self.imgViewPhoto = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.imgViewPhoto.userInteractionEnabled = YES;
        self.imgViewPhoto.layer.cornerRadius = 5;
        self.imgViewPhoto.layer.masksToBounds = YES;
        self.imgViewPhoto.backgroundColor = [UIColor whiteColor];
        self.imgViewPhoto.clipsToBounds = YES;
        self.imgViewPhoto.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:self.imgViewPhoto];
    }
    return self;
}

- (void)initWithAttachment:(AttachmentVo*)attachmentVo
{
    attachmentVoData = attachmentVo;
    
    self.imgViewPhoto.frame = CGRectMake(4,4,69,69);
    UIImage *imgDefault =[UIImage imageNamed:@"default_image"];
    
    if ([attachmentVo.strType isEqualToString:@"audio"])
    {
        self.imgViewPhoto.image = [UIImage imageNamed:@"message_video_icon"];
    }
    else
    {
        [self.imgViewPhoto sd_setImageWithURL:[NSURL URLWithString:attachmentVo.strAttachmentURL] placeholderImage:imgDefault];
    }
}

@end
